package cn.ly.design.action.state;

public class StateTest {
	public static void main(String[] args) {
		QQ myqq = new QQ();
		State s = new OnlineState();
		myqq.changeState(s);
		s = new StealthState();
		myqq.changeState(s);
		s = new BusyState();
		myqq.changeState(s);
	}
	
}

class QQ{
	private State s;
	public void changeState(State s){
		this.s = s;
		s.action();
	}
	
}

abstract class State{
	protected abstract void action();
}

class StealthState extends State{
	public void action(){
		System.out.println("变灰色，让别人看不见我");
	}
}

class BusyState extends State{
	public void action(){
		System.out.println("进入免打扰模式");
	}
}

class OnlineState extends State{
	public void action(){
		System.out.println("闪亮登场，声音提醒");
	}
}

